<template>
  <ul class="grid-nav">
    <li
      v-for="(item, index) in shortCut"
      :key="index"
      @click="gotoRank(item.url, item.name)"
    >
      <div><img :src="item.cover" alt="" /></div>
      <div class="text">{{ item.name }}</div>
    </li>
  </ul>
</template>

<script>
export default {
  props: {
    shortCut: {
      type: Array,
      default: [],
    },
  },
  data() {
    return {};
  },
  methods: {
    gotoRank(url, name) {
      let _url = "";
      if (url.indexOf(".json") != -1) {
        _url = "https://apis.netstart.cn/yunyuedu" + url;
      } else {
        _url = url;
      }
      switch (name) {
        case "完本":
          name = "完本畅读";
          break;
        case "特价":
          name = "本周出版书特价";
          break;
        case "影视":
          name = "【出版】影视原著";
          break;
        case "经典":
          name = "经典作品";
          break;
        default:
          name = name;
      }
      this.$emit("triggeEvent", [_url, name]);
    },
  },
};
</script>

  
<style lang="scss" scoped>
.grid-nav {
  display: flex;
  width: 100%;
  margin-top: 10px;
  margin-bottom: 10px;
  li {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 16px;
    img {
      width: 50px;
    }
  }
}
</style>